﻿@{
    ViewData["Title"] = "Jurisdiction";
}

@model Sikiro.Web.Admin.Models.Role.AddRoleModel

<layuiForm id="layuiadmin-form-admin" style="padding: 20px">

    <div id="tree"></div>

</layuiForm>

@section Scripts
{
    <script>
        var tree = layui.tree;

        $.post("/role/JurisdictionTree",
            { id: '@ViewBag.Id' },
            function(data) {
                tree.render({
                    elem: '#tree',
                    showCheckbox: true,
                    id: "jurisdiction",
                    data: data
                });
            });

        $(function() {
            layui.form.on('submit(btn-submit)',
                function () {
                    var checkData = tree.getChecked("jurisdiction");

                    $.ajaxPost("/Role/Jurisdiction", { id:' @ViewBag.Id',model: checkData}, function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                });
        });

    </script>
}